package name.huzhenbo.java.patterns.visitor;

class DataContainer {
    private int income;
    private int cost;
    private int operationCost;
    private boolean excludeOperationCost;

    public DataContainer(int income, int cost, int operationCost) {
        this.income = income;
        this.cost = cost;
        this.operationCost = operationCost;
    }

    public int getIncome() {
        return income;
    }

    public int getCost() {
        return cost;
    }

    public int getOperationCost() {
        return operationCost;
    }

    public void setExcludeOperationCost(boolean excludeOperationCost) {
        this.excludeOperationCost = excludeOperationCost;
    }

    public void accept(ProfitVisitor visitor) {
        visitor.visit(this);
    }

    public int getProfit() {
        if (excludeOperationCost) {
            return income - cost - operationCost;
        } else {
            return income - cost;
        }
    }
}
